﻿using UnityEngine;

namespace Assets.Scripts
{
    /// <summary>
    /// 球拍的控制器.
    /// </summary>
    public class RacketController : MonoBehaviour
    {
        private static RacketController _instance;

        public static RacketController Instance
        {
            get { return _instance; }
        }

        /// <summary>
        /// 玩家的球拍.
        /// </summary>
        private Racket _playerRacket;

        private void Awake()
        {
            _instance = this;
            InitWidget();
        }

        /// <summary>
        /// 获取组件函数.
        /// </summary>
        private void InitWidget()
        {
            _playerRacket = GameObject.Find("PlayerRacket").GetComponent<Racket>();
        }

        private void Update()
        {
            //TODO:这里改成只输入+1/-1可能会更好.
            //每帧判断键盘的输入.
            var v = Input.GetAxis("Vertical");
            _playerRacket.Move(v);
        }
    }
}
